// https://leetcode.cn/problems/max-number-of-k-sum-pairs/description/


func maxOperations(nums []int, k int) int {
    rec := make(map[int]int)
	ans := 0
	for i := range nums {
		if v, _ := rec[nums[i]]; v > 0 {
			ans++
			rec[nums[i]]--
			continue
		}
		rec[k - nums[i]]++
	}
	return ans
}